import QtQuick 2.5
//import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4



    TableView{
        id :tableView
//        anchors.fill: parent
        alternatingRowColors : false

//        tableView.viewport.width/tableView.columnCount
        TableViewColumn {
            role: "numberRole"
            title: "编号"
//            width: tableView.viewport.width/9*1
            width: parent.width/9*1
            }

        TableViewColumn {
            role: "DataRole"
            title: "内容"
//            width: tableView.viewport.width/9*4
            width: parent.width/9*4
        }

        TableViewColumn {
            role: "HeadRole"
            title: "标题"
//            width: tableView.viewport.width/9*2
            width: parent.width/9*2
        }

        TableViewColumn {
            role: "DateRole"
            title: "日期"
//            width: tableView.viewport.width/9*2
            width: parent.width/9*2
        }



          model: theModel

          //自定义表头代理
           headerDelegate:
           Rectangle{
               //color: "#00498C"
               gradient: Gradient {
                   GradientStop { position: 0.0; color: "#085FB2" }
                   GradientStop { position: 1.0; color: "#00498C" }
               }
               color : styleData.selected ? "blue": "darkgray"
               width: 100;
               height: 40
               border.color: "black"
               //border.width: 1
               //radius: 5
               Text
                {
                    anchors.centerIn : parent
                    text: styleData.value
                    font.pixelSize: parent.height*0.5
                }
           }

//       行代理可以修改行高等信息
       rowDelegate: Rectangle {
           height: 50
           color: "#052641"
           anchors.leftMargin: 2

       }

       itemDelegate: Rectangle{
           //color: "#052641"
           border.width: 1
           color : styleData.selected ? "#dd00498C": "#052641"
           Text{

                anchors.verticalCenter: parent.verticalCenter
                //anchors.fill: parent
                anchors.leftMargin: 5
                color : styleData.selected ? "#00CCFE": "white"
                elide: Text.ElideRight
                text: styleData.value
                width: parent.width
                height: parent.height
                verticalAlignment: Text.AlignVCenter//垂直中心
                horizontalAlignment: {
                    if(styleData.role !== "DataRole")
                    {
                        //水平中心对齐
                       return  Text.AlignHCenter
                    }else{
                        //左对齐
                        return  Text.AlignLeft
                    }
                }
                font.pixelSize: parent.height*0.4
            }

       }




         style: TableViewStyle{
             textColor: "white"
             highlightedTextColor : "#00CCFE"  //选中的颜色
             backgroundColor : "#052641"

         }
    }
//}

